#include "helpwidget.h"
#include "ui_helpwidget.h"

HelpWidget::HelpWidget(QWidget *parent)
    : QWidget(parent, Qt::FramelessWindowHint | Qt::Window | Qt::WindowMinimizeButtonHint)
    , ui(new Ui::HelpWidget)
{
    setWindowFlag(Qt::FramelessWindowHint, true);
    setWindowFlag(Qt::Window, true);
    setWindowFlag(Qt::WindowMinimizeButtonHint, true);
    setAttribute(Qt::WA_TranslucentBackground);

    ui->setupUi(this);
}

HelpWidget::~HelpWidget()
{
    delete ui;
}

void HelpWidget::mousePressEvent(QMouseEvent*event)
{
    if(event->button()==Qt::LeftButton) //如果鼠标左键按下
    {
        isPressed=true;
        curPos = event->pos();    //记录当前的点击坐标
    }
}

void HelpWidget::mouseMoveEvent(QMouseEvent*event)
{
    if(isPressed) //如果鼠标左键按下
    {
        this->move(event->pos()-curPos+this->pos());
        //窗口移动
    }
}

//鼠标释放
void HelpWidget::mouseReleaseEvent(QMouseEvent*event)
{
    isPressed=false;
}

void HelpWidget::paintEvent(QPaintEvent *event)
{
    QStyleOption opt;
    opt.init(this);
    QPainter painter(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
}

